package com.sc.admin.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sc.admin.common.MysqlQuery;
import com.sc.admin.mapper.RoleMapper;
import com.sc.admin.pojo.Role;

@Service
public class RoleServiceImpl implements RoleService {
	@Autowired
	private RoleMapper roleMapper;
	
	@Override
	public List<Role> getRoles(int page, int row) {
		return roleMapper.selectRoles(new MysqlQuery(page, row));
	}

	@Override
	public int getCount() {
		return roleMapper.selectCount();
	}

	@Override
	public void add(Role role) {
		roleMapper.insertSelective(role);
	}

	@Override
	public Role checkName(String name) {
		return roleMapper.selectRoleByName(name);
	}

	@Override
	public Role getRoleById(int id) {
		return roleMapper.selectByPrimaryKey(id);
	}

	@Override
	public void update(Role role) {
		roleMapper.updateByPrimaryKeySelective(role);
	}

	@Override
	public void delete(int id) {
		roleMapper.deleteByPrimaryKey(id);
	}

	@Override
	public List<Role> getAllRoles() {
		return roleMapper.selectAll();
	}

}
